import numpy as np
import cv2
import os
import glob
import string

def access_pixels(frame,filename):
        print(frame.shape)
        height = frame.shape[0]
        weight = frame.shape[1]
        channels = frame.shape[2]
        if channels > 3:
                for row in range(height):
                        for col in range(weight):
                                pv = frame[row, col, 3]
                                if pv != 255:
                                        frame[row, col] = [0, 0, 0, 0]
        addr = path_change + filelist[len(path):]
        cv2.imwrite(addr, img)


path = 'E:/Object/TouchGFX/Main_menu/assets/images'
path_change = 'E:/Object/TouchGFX/Main_menu/assets/images/change'
for filelist in glob.glob(path+'/*.png'):
        
        img = cv2.imread(filelist, cv2.IMREAD_UNCHANGED)
        access_pixels(img,filelist)


k = cv2.waitKey(0)

if k == 27:
        cv2.destroyAllWindows()
elif k == ord('s'):
        
        cv2.destroyAllWindows()


